﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GamovMvc.Framework.Url
{
    public class RouteTable
    {
        public static IList<Route> Routes
        {
            get;
            set;
        }

        static RouteTable()
        {
            Routes = new List<Route>();
        }

        /// <summary>
        /// 获取路由匹配的路由对象
        /// </summary>
        /// <param name="url"></param>
        /// <param name="dictRoutes"></param>
        /// <returns></returns>
        public static Route GetMatchRoutes(string url, out IDictionary<string, object> dictRoutes)
        {
            dictRoutes = null;
            foreach (var route in Routes)
            {
                if (route.MatchUrl(url, out dictRoutes))
                {
                    return route;
                }
            }
            return null;
        }
    }
}
